﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class UIPanelMgr : Singleton<UIPanelMgr>
{
    private readonly Stack<UIPanel> _panelStack = new Stack<UIPanel>();
    public void Enter(UIPanel panel)
    {
        //隐藏栈顶Panel
        if (_panelStack.Count != 0)
        {
            UIPanel topPanel = _panelStack.Pop();
            topPanel.Hide();
        }

        //新Panel进栈
        _panelStack.Push(panel);
        panel.Show();
    }

    public void Leave()
    {
        if (_panelStack.Count != 0)
        {
            UIPanel panel = _panelStack.Pop();
            panel.Hide();
        }
    }

}
